
function AddOverride(addon, func)
   AddEventListener('PLAYER_LOGIN', function()
      if not IsAddOnLoaded(addon) then
         return
      end
      print('Overriding ' .. addon)
      func()
   end)
end

-------------------------------------------------------------------------------
local function OverrideDev()
   _DevFont:SetFont('Fonts\\ARIALN.ttf', 11)
   local fontDisplay = CreateFrame('FRAME', 'SpyFontDisplay', UIParent)
   fontDisplay.txt = fontDisplay:CreateFontString(nil, 'OVERLAY', _DevFont)
   fontDisplay.txt:SetFont('Fonts\\ARIALN.ttf', 11)
   fontDisplay.txt:SetAllPoints()
   fontDisplay:SetFrameStrata('TOOLTIP')
   fontDisplay.back = fontDisplay:CreateTexture(nil, "BACKGROUND")
   fontDisplay.back:SetAllPoints()
   fontDisplay.back:SetTexture(0, 0, 0)
   fontDisplay.back:SetAlpha(1)
   fontDisplay:Hide()

   local Primary = _Dev.Frames.Primary
   function Primary:OnMouseWheel(delta)
      local f = self.Target
      if f.SetFont and f.GetFont then
         local font, size = f:GetFont()
         local newSize = max(size + delta, 0)
         f:SetFont(font, newSize)
         print(newSize)
      end
   end
   Primary:SetScript('OnMouseWheel', Primary.OnMouseWheel)
   
   local oldSetTarget = Primary.SetTarget
   function Primary:SetTarget(target)
      oldSetTarget(self, target)
      if target and target.GetFont then
         local font, size = target:GetFont()
         font = GetFileName(font)
         size = round(size)
         local text = format('%s (%d)', font, size)
         fontDisplay.txt:SetText(text)
         fontDisplay:SetWidth(fontDisplay.txt:GetStringWidth() + 10)
         fontDisplay:SetHeight(fontDisplay.txt:GetStringHeight())
         fontDisplay:SetPoint('BOTTOMLEFT', target, 'TOPLEFT', 0, 4)
         fontDisplay:Show()
      else
         fontDisplay:ClearAllPoints()
         fontDisplay:Hide()
      end
   end
   
   -- function _Dev.Outline:OnSetTarget(target)
   -- end
end

AddOverride('_Dev', OverrideDev)
AddOverride('WowLua', function()
   local font = Font('Consolas')
   local size = 12
   WowLuaFrameEditBox:SetFont(font, size)
   WowLuaFrameLineNumEditBox:SetFont(font, size)
   WowLuaFrameOutput:SetFont(font, size)
   WowLuaFrameCommandEditBox:SetFont(font, size)
end)

